from enum import Enum
from typing import Literal, TypeAlias


# From pygame.key
class VE_KEYMAP(Enum):
    K_BACKSPACE      = 8            # \b   backspace
    K_TAB            = 9            # \t   tab
    K_CLEAR          = 1073741980   #      clear
    K_RETURN         = 13           # \r   return
    K_PAUSE          = 1073741896   #      pause
    K_ESCAPE         = 27           # ^[   escape
    K_SPACE          = 32           #      space
    K_EXCLAIM        = 33           # !    exclaim
    K_QUOTEDBL       = 34           # "    quotedbl
    K_HASH           = 35           # #    hash
    K_DOLLAR         = 36           # $    dollar
    K_AMPERSAND      = 38           # &    ampersand
    K_QUOTE          = 39           #      quote
    K_LEFTPAREN      = 40           # (    left parenthesis
    K_RIGHTPAREN     = 41           # )    right parenthesis
    K_ASTERISK       = 42           # *    asterisk
    K_PLUS           = 43           # +    plus sign
    K_COMMA          = 44           # ,    comma
    K_MINUS          = 45           # -    minus sign
    K_PERIOD         = 46           # .    period
    K_SLASH          = 47           # /    forward slash
    K_0              = 48           # 0    0
    K_1              = 49           # 1    1
    K_2              = 50           # 2    2
    K_3              = 51           # 3    3
    K_4              = 52           # 4    4
    K_5              = 53           # 5    5
    K_6              = 54           # 6    6
    K_7              = 55           # 7    7
    K_8              = 56           # 8    8
    K_9              = 57           # 9    9
    K_COLON          = 58           # :    colon
    K_SEMICOLON      = 59           # ;    semicolon
    K_LESS           = 60           # <    less-than sign
    K_EQUALS         = 61           # =    equals sign
    K_GREATER        = 62           # >    greater-than sign
    K_QUESTION       = 63           # ?    question mark
    K_AT             = 64           # @    at
    K_LEFTBRACKET    = 91           # [    left bracket
    K_BACKSLASH      = 92           # \    backslash
    K_RIGHTBRACKET   = 93           # ]    right bracket
    K_CARET          = 94           # ^    caret
    K_UNDERSCORE     = 95           # _    underscore
    K_BACKQUOTE      = 96           # `    grave
    K_a              = 97           # a    a
    K_b              = 98           # b    b
    K_c              = 99           # c    c
    K_d              = 100          # d    d
    K_e              = 101          # e    e
    K_f              = 102          # f    f
    K_g              = 103          # g    g
    K_h              = 104          # h    h
    K_i              = 105          # i    i
    K_j              = 106          # j    j
    K_k              = 107          # k    k
    K_l              = 108          # l    l
    K_m              = 109          # m    m
    K_n              = 110          # n    n
    K_o              = 111          # o    o
    K_p              = 112          # p    p
    K_q              = 113          # q    q
    K_r              = 114          # r    r
    K_s              = 115          # s    s
    K_t              = 116          # t    t
    K_u              = 117          # u    u
    K_v              = 118          # v    v
    K_w              = 119          # w    w
    K_x              = 120          # x    x
    K_y              = 121          # y    y
    K_z              = 122          # z    z
    K_DELETE         = 127          #      delete
    K_KP0            = 1073741922   #      keypad 0
    K_KP1            = 1073741913   #      keypad 1
    K_KP2            = 1073741914   #      keypad 2
    K_KP3            = 1073741915   #      keypad 3
    K_KP4            = 1073741916   #      keypad 4
    K_KP5            = 1073741917   #      keypad 5
    K_KP6            = 1073741918   #      keypad 6
    K_KP7            = 1073741919   #      keypad 7
    K_KP8            = 1073741920   #      keypad 8
    K_KP9            = 1073741921   #      keypad 9
    K_KP_PERIOD      = 1073741923   # .    keypad period
    K_KP_DIVIDE      = 1073741908   # /    keypad divide
    K_KP_MULTIPLY    = 1073741909   # *    keypad multiply
    K_KP_MINUS       = 1073741910   # -    keypad minus
    K_KP_PLUS        = 1073741911   # +    keypad plus
    K_KP_ENTER       = 1073741912   # \r   keypad enter
    K_KP_EQUALS      = 1073741927   # =    keypad equals
    K_UP             = 1073741906   #      up arrow
    K_DOWN           = 1073741905   #      down arrow
    K_RIGHT          = 1073741903   #      right arrow
    K_LEFT           = 1073741904   #      left arrow
    K_INSERT         = 1073741897   #      insert
    K_HOME           = 1073741898   #      home
    K_END            = 1073741901   #      end
    K_PAGEUP         = 1073741899   #      page up
    K_PAGEDOWN       = 1073741902   #      page down
    K_F1             = 1073741882   #      F1
    K_F2             = 1073741883   #      F2
    K_F3             = 1073741884   #      F3
    K_F4             = 1073741885   #      F4
    K_F5             = 1073741886   #      F5
    K_F6             = 1073741887   #      F6
    K_F7             = 1073741888   #      F7
    K_F8             = 1073741889   #      F8
    K_F9             = 1073741890   #      F9
    K_F10            = 1073741891   #      F10
    K_F11            = 1073741892   #      F11
    K_F12            = 1073741893   #      F12
    K_F13            = 1073741928   #      F13
    K_F14            = 1073741929   #      F14
    K_F15            = 1073741930   #      F15
    K_NUMLOCK        = 1073741907   #      numlock
    K_CAPSLOCK       = 1073741881   #      capslock
    K_SCROLLOCK      = 1073741895   #      scrollock
    K_RSHIFT         = 1073742053   #      right shift
    K_LSHIFT         = 1073742049   #      left shift
    K_RCTRL          = 1073742052   #      right control
    K_LCTRL          = 1073742048   #      left control
    K_RALT           = 1073742054   #      right alt
    K_LALT           = 1073742050   #      left alt
    K_RMETA          = 1073742055   #      right meta
    K_LMETA          = 1073742051   #      left meta
    K_LSUPER         = 1073742051   #      left Windows key
    K_RSUPER         = 1073742055   #      right Windows key
    K_MODE           = 1073742081   #      mode shift
    K_HELP           = 1073741941   #      help
    K_PRINT          = 1073741894   #      print screen
    K_SYSREQ         = 1073741978   #      sysrq
    K_BREAK          = 1073741896   #      break
    K_MENU           = 1073741942   #      menu
    K_POWER          = 1073741926   #      power
    K_EURO           = 1073742004   #      Euro
    K_AC_BACK        = 1073742094   #      Android back button
    
    M_LEFT           = 1            #      Mouse left button
    M_MIDDLE         = 2            #      Mouse middle button
    M_RIGHT          = 3            #      Mouse right button
    M_WHEELUP        = 4            #      Mouse wheel up
    M_WHEELDOWN      = 5            #      Mouse wheel down

MAP_KEYBOARD: dict[str, int] = {}
MAP_MOUSE: dict[str, int] = {}
for name, member in VE_KEYMAP._member_map_.items():
    if name.startswith("K_"):
        MAP_KEYBOARD[name] = member.value
    elif name.startswith("M_"):
        MAP_MOUSE[name] = member.value

MOUSE = [VE_KEYMAP.M_LEFT, VE_KEYMAP.M_MIDDLE, VE_KEYMAP.M_RIGHT, VE_KEYMAP.M_WHEELUP, VE_KEYMAP.M_WHEELDOWN]